module.exports = {
  transpileDependencies: ['webpack-dev-server/client'],
  chainWebpack: config => {
    config.entry.app = ['babel-polyfill', './src/main.js'];
    if (process.env.NODE_ENV === 'production') {
      if (config.has("externals")) {
        config.externals.set("xe-utils", "xe-utils").set("moment", "moment").set("lodash", 'lodash').set("china-area-data", "china-area-data")
      } else {
        config.set("externals", {
          "xe-utils": "xe-utils",
          "china-area-data": "china-area-data",
          moment: "moment",
          lodash: 'lodash',
        })
      }
    }
  },
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: false,
  css: {
    extract:  ['production', 'development'].includes(process.env.NODE_ENV),
    loaderOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  configureWebpack:{
    optimization: {
      minimize: true
    }
  }
}

